package com.mengya.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @ClassName CASDemo
 * @Description
 * @Author xiongwei.wu
 * @Date 2023/1/13 15:12
 **/
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        System.out.println(atomicInteger.get());

        System.out.println(atomicInteger.compareAndSet(5, 2000) + "\t" + atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 2020) + "\t" + atomicInteger.get());
    }
}
